<script language=javascript>
//for messeage to invit
<%if @func==-2 %>
	var obj=parent.window.document.getElementById('recipient_list');
	if(obj)
	{
		alert("An invitation has been sent to "+ obj.value);
		obj.value='';
	}
<% end %>

//for index/index
<%unless @topest_users.nil? %>
var data_b=[];
<% uid=session[:user_id].to_i %>
<% i=0 %>
<% @newest_users.each do |user| %>
<% #if(user.id!=uid) %>
	data_b[<%=i%>]=[];
	data_b[<%=i%>][0]=<%=user.id%>;
	data_b[<%=i%>][1]='<%=h user.login.gsub(/\'/,"\\\\'")%>';
	data_b[<%=i%>][2]=<%=user.usercount%>;
<%if(user.id!=uid) %>
	data_b[<%=i%>][3]="<a target=emptywin href=/friend/topestnewst?type=<%=@manager.is_joined(user.id) ?'leave':'join'%>&friend_id=<%=user.id%>><%=@manager.is_joined(user.id) ?'leave':'join'%></a>";
	data_b[<%=i%>][4]="<a target=emptywin  href=/friend/topestnewst?type=<%=@manager.is_friend(user.id) ?'remove':'add'%>&friend_id=<%=user.id%>><%=@manager.is_friend(user.id) ?'remove':'add'%></a>";	
<%else %>
	data_b[<%=i%>][3]='mine';
	data_b[<%=i%>][4]='self';
<%end %>
	data_b[<%=i%>][5]="<%=h user.interests.gsub(/\'/,"\\\\'") %>";
	<%i=i+1%>
<% #end%>
<%end%>
var data_a=[];
<% i=0 %>
<% @topest_users.each do |user| %>
<% #if(user.id!=uid) %>
	data_a[<%=i%>]=[];
	data_a[<%=i%>][0]=<%=user.id%>;
	data_a[<%=i%>][1]='<%=h user.login.gsub(/\'/,"\\\\'")%>';
	data_a[<%=i%>][2]=<%=user.usercount%>;
<%if(user.id!=uid) %>
	data_a[<%=i%>][3]="<a target=emptywin href=/friend/topestnewst?type=<%=@manager.is_joined(user.id) ?'leave':'join'%>&friend_id=<%=user.id%>><%=@manager.is_joined(user.id) ?'leave':'join'%></a>";
	data_a[<%=i%>][4]="<a target=emptywin  href=/friend/topestnewst?type=<%=@manager.is_friend(user.id) ?'remove':'add'%>&friend_id=<%=user.id%>><%=@manager.is_friend(user.id) ?'remove':'add'%></a>";	
<%else %>
	data_a[<%=i%>][3]='mine';
	data_a[<%=i%>][4]='self';
<%end %>
	data_a[<%=i%>][5]="<%=h user.interests.gsub(/\'/,"\\\\'") %>";
	<%i=i+1%>
<% #end%>
<%end%>
if(parent.setdata)
	parent.setdata(data_b,data_a);
<% end %>

<%unless @results.nil? %>
if(parent.setpage)
	parent.setpage(<%=@count.to_i%>,<%=@page.to_i%>,'<%=@action%>');
var data_a=[];
<% uid=session[:user_id].to_i %>
<% i=0 %>
<% @results.each do |user| %>
<% #if(user.id!=uid) %>
	data_a[<%=i%>]=[];
	data_a[<%=i%>][0]=<%=user.id%>;
	data_a[<%=i%>][1]='<%=h user.login.gsub(/\'/,"\\\\'")%>';
	data_a[<%=i%>][2]=<%=user.usercount%>;
<%if(user.id!=uid) %>
	data_a[<%=i%>][3]="<a target=emptywin href=/friend/netop?type=<%=@manager.is_joined(user.id) ?'leave':'join'%>&friend_id=<%=user.id%>><%=@manager.is_joined(user.id) ?'leave':'join'%></a>";
	data_a[<%=i%>][4]="<a target=emptywin  href=/friend/netop?type=<%=@manager.is_friend(user.id) ?'remove':'add'%>&friend_id=<%=user.id%>><%=@manager.is_friend(user.id) ?'remove':'add'%></a>";	
<%else %>
	data_a[<%=i%>][3]='mine';
	data_a[<%=i%>][4]='self';
<%end %>
	data_a[<%=i%>][5]="<%=h user.interests.gsub(/\'/,"\\\\'") %>";
	<%i=i+1%>
<% #end%>
<%end%>
	if(parent.setdata)
		parent.setdata(data_a,<%=@func%>);
<% end %>
<%unless @result.nil? %>
<%user=@result%>
if(parent.setrow)
	parent.setrow([<%=user.id%>,'<%=h user.login.gsub(/\'/,"\\\\'")%>',<%=user.usercount%>,"<a target=emptywin href=/friend/netop?type=<%=@manager.is_joined(user.id) ?'leave':'join'%>&friend_id=<%=user.id%>><%=@manager.is_joined(user.id) ?'leave':'join'%></a>","<a target=emptywin  href=/friend/netop?type=<%=@manager.is_friend(user.id) ?'remove':'add'%>&friend_id=<%=user.id%>><%=@manager.is_friend(user.id) ?'remove':'add'%></a>","<%=h user.interests.gsub(/\'/,"\\\\'") %>",]);
<% end %>
<%unless @me.nil? %>
if(parent.setme)
{
	var myinfo=['<%=h @me.login.gsub(/\'/,"\\\\'")%>','<%=h @me.adsense_id.gsub(/\'/,"\\\\'")%>','<%=@me.hashkey%>','<%=h @me.email.gsub(/\'/,"\\\\'")%>','<%=h @me.interests.gsub(/\'/,"\\\\'")%>',<%=@me.is_public%>,<%=@me.notifyme%>];
	parent.setme(myinfo,<%=@me.is_guest%>);
}
<% end %>
<%if @func==-102 %>
	alert("your information has been updated successfully!");
<% end %>
<%if @func==-103 %>
	alert("your email has been used by other user!");
<% end %>
<%if @func==-101 %>
	alert("You password is not right, update failed!");
<% end %>
</script>